#include "pointer.h"

Pointer::Pointer(int* p)
{
    mp = p;
}

Pointer::Pointer(const Pointer& obj)
{
    mp = obj.mp;
    const_cast<Pointer&>(obj).mp = nullptr;
}

Pointer& Pointer::operator = (const Pointer& obj)
{
    if( this != &obj)
    {
        delete mp;
        mp = obj.mp;
        const_cast<Pointer&>(obj).mp = nullptr;
    }
    return *this;
}

int* Pointer::operator -> ()
{
    return mp;
}

int& Pointer::operator * ()
{
    return *mp;
}

bool Pointer::isNull()
{
    return (mp == nullptr);
}

Pointer::~Pointer()
{
    delete mp;
}
